<template>
  <div>
    <el-table
      :data="tableData"
      style="width: 100%"
      :row-class-name="tableRowClassName">
      <el-table-column
        prop="tribunal_describe"
        label="描述"
        width="400">
      </el-table-column>
      <el-table-column
        prop="name"
        label="买家:卖家"
        width="180">
        <template slot-scope="scope">
          <span style="margin-left: 10px">{{ scope.row.user_vote }}:{{ scope.row.store_vote }}</span>
        </template>
      </el-table-column>
      <el-table-column
        prop="result"
        label="结果">
      </el-table-column>
      <el-table-column
        prop="status"
        label="状态"
        :filters="[{ text: '收集证据中', value: 0 }, { text: '评审中', value: 1 }, { text: '已结案', value: 2 }]"
        :filter-method="filterStatus"
        filter-placement="bottom-end"
      >
        <template slot-scope="scope">
          <el-tag type="danger" effect="dark" v-if="scope.row.status==0">收集证据中</el-tag>
          <el-tag type="success" effect="dark" v-if="scope.row.status==1">评审中</el-tag>
          <el-tag type="warning" effect="dark" v-if="scope.row.status==2">已结案</el-tag>
        </template>
      </el-table-column>
      <el-table-column
        fixed="right"
        label="操作"
        width="100">
        <template slot-scope="scope">
          <el-button @click="handleClick(scope.row)" type="text" size="small">查看</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
export default {
  name: "myTribunal",
  data() {
    return {
      tableData: [],
      username: sessionStorage.getItem("username"),
    }
  },
  created() {
    this.getMyTribunal()
  },
  methods: {
    async getMyTribunal() {
      const res = await this.$axios.get("/tribunal/getMyTribunalByUserName",{
        params: {
          user_name: sessionStorage.getItem("username")
        }
      })
      this.tableData = res.list
    },
    handleClick(row) {
      this.$router.push({
        path: "/tribunal/tribunalDetail",
        query: {
          tribunal_id: row.tribunal_id,
          good_id: row.good_id,
          orderNo: row.orderNo,
        }
      })
    },
    tableRowClassName({row, rowIndex}) {
      if (rowIndex === 1) {
        return 'warning-row';
      } else if (rowIndex === 3) {
        return 'success-row';
      }
      return '';
    },
    filterStatus(value, row) {
      return row.status === value;
    },
  },
}
</script>

<style scoped>

</style>
